
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.soldier.dto.CommonSignInfoBSearcher;
import com.insigma.business.qrcode.soldier.dto.CommonSignInfoDTO;
import com.insigma.business.qrcode.soldier.entity.CommonSignInfoDO;
import com.insigma.business.qrcode.soldier.request.CommonSignInfoInsertRequest;
import com.insigma.business.qrcode.soldier.request.CommonSignInfoSearchRequest;
import com.insigma.business.qrcode.soldier.request.CommonSignInfoUpdateRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class CommonSignInfoProviderConverter extends AbstractConverter<CommonSignInfoDTO, CommonSignInfoDO> {

    private final static CommonSignInfoProviderConverter commonSignInfoConverter = new CommonSignInfoProviderConverter();

    private CommonSignInfoProviderConverter(){}

    
    public static CommonSignInfoBSearcher convertRequestSO2Searcher(final CommonSignInfoSearchRequest request){
        final CommonSignInfoBSearcher commonSignInfoBSearcher = new CommonSignInfoBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,commonSignInfoBSearcher);
        return commonSignInfoBSearcher;
    }

    
    public static CommonSignInfoDO convertRequestUO2DO(final CommonSignInfoUpdateRequest commonSignInfoUpdateRequest) {
        final CommonSignInfoDO commonSignInfoDO = new CommonSignInfoDO();
        BeanUtils.copyProperties(commonSignInfoUpdateRequest,commonSignInfoDO);
        
        return commonSignInfoDO;
    }

    
    public static CommonSignInfoDO convertRequestIO2DO(final CommonSignInfoInsertRequest commonSignInfoInsertRequest) {
        final CommonSignInfoDO commonSignInfoDO = new CommonSignInfoDO();
        BeanUtils.copyProperties(commonSignInfoInsertRequest,commonSignInfoDO);
        return commonSignInfoDO;
    }

    
    public static List<CommonSignInfoDTO> convertResponseDOList2DTOList(final List<CommonSignInfoDO> commonSignInfoDOList){
        return commonSignInfoConverter.convertGenericResponseDOList2DTOList(commonSignInfoDOList);
    }

    
    public static CommonSignInfoDTO convertResponseDO2DTO(final CommonSignInfoDO commonSignInfoDO){
        return commonSignInfoConverter.convertGenericResponseDO2DTO(commonSignInfoDO);
    }

    
    @Override
    protected CommonSignInfoDTO doConvertResponseDO2DTO(CommonSignInfoDO commonSignInfoDO) {
        final CommonSignInfoDTO commonSignInfoDTO = new CommonSignInfoDTO();
        try {
            BeanUtils.copyProperties(commonSignInfoDO, commonSignInfoDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return commonSignInfoDTO;
    }

}
